package org.example.kidscode.service.impl;

import org.example.kidscode.entity.ClassCard;
import org.example.kidscode.repository.ClassCardRepository;
import org.example.kidscode.service.ClassCardService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDate;
import java.util.List;
import java.util.Optional;

@Service
@Transactional
public class ClassCardServiceImpl implements ClassCardService {

    private final ClassCardRepository classCardRepository;

    public ClassCardServiceImpl(ClassCardRepository classCardRepository) {
        this.classCardRepository = classCardRepository;
    }

    @Override
    public List<ClassCard> findAll() {
        return classCardRepository.findAll();
    }

    @Override
    public Optional<ClassCard> findById(String cardId) {
        return classCardRepository.findById(cardId);
    }

    @Override
    public ClassCard save(ClassCard classCard) {
        return classCardRepository.save(classCard);
    }

    @Override
    public void deleteById(String cardId) {
        classCardRepository.deleteById(cardId);
    }

    @Override
    public List<ClassCard> findByStudentId(String studentId) {
        return classCardRepository.findByStudentId(studentId);
    }

    @Override
    public List<ClassCard> findByExpireDateBefore(LocalDate date) {
        return classCardRepository.findByExpireDateBefore(date);
    }
}